package com.huya.mapper;

import com.github.pagehelper.Page;
import com.huya.pojo.dto.LegalPageQueryDTO;
import com.huya.pojo.entity.Legal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LegalMapper {
    /**
     * 分页查询法律法规
     * @param legalPageQueryDTO
     * @return
     */
    Page<Legal> pageQuery(LegalPageQueryDTO legalPageQueryDTO);

    /**
     * 根据法律法规id查询法律法规
     * @param id
     * @return
     */
    @Select("SELECT * FROM legal_regulations WHERE id = #{id}")
    Legal selectByLegalId(Long id);

    /**
     * 根据id列表批量删除法律法规
     * @param ids
     */
    void deleteByLegalIds(List<Long> ids);

    /**
     * 更新法律法规
     * @param legal
     */
    void update(Legal legal);

    @Insert("INSERT INTO legal_regulations(title, issuing_authority, release_date, effective_date, category, description, text_link, hot_ranking, update_time) " +
            "VALUES" +
            "(#{title}, #{issuingAuthority}, #{releaseDate}, #{effectiveDate}, #{category}, #{description}, #{textLink}, #{hotRanking}, #{updateTime})   ")
    void insert(Legal legal);
}
